module spreadsheet_cell;

import <iostream>;
import <string>;

namespace spreadsheet
{
	SpreadsheetCell::SpreadsheetCell()
	{
		//std::cout << "SpreassheetCell()" << std::endl;
	}

	SpreadsheetCell::SpreadsheetCell(double value)
		: m_value{ value }
	{
		//std::cout << "SpreassheetCell(double)" << std::endl;
	}

	SpreadsheetCell::SpreadsheetCell(std::string_view value)
		:m_value{ std::stod(std::string(value)) }
	{
		//std::cout << "SpreassheetCell(std::string_view value)" << std::endl;
	}

	SpreadsheetCell::~SpreadsheetCell()
	{
		//std::cout << "~SpreassheetCell()" << std::endl;
	}


	void SpreadsheetCell::setValue(double value)
	{
		m_value = value;
	}

	double SpreadsheetCell::getValue() const
	{
		return m_value;
	}

	std::string_view SpreadsheetCell::getString() const
	{
		return std::to_string(m_value);
	}

	SpreadsheetCell SpreadsheetCell::operator+(const SpreadsheetCell &rhs) const
	{
		return SpreadsheetCell{ getValue() + rhs.getValue() };
	}

	bool SpreadsheetCell::operator==(const SpreadsheetCell &rhs) const
	{
		return getValue() == rhs.getValue();
	}

	std::partial_ordering SpreadsheetCell::operator<=>(const SpreadsheetCell &rhs) const
	{
		return getValue() <=> rhs.getValue();
	}

	bool SpreadsheetCell::operator==(double rhs) const
	{
		return getValue() == rhs;
	}

	std::partial_ordering SpreadsheetCell::operator<=>(double rhs) const
	{
		return getValue() <=> rhs;
	}
}